﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Logic;

namespace Presentation
{
	public partial class RenamingSettings : UserControl
	{
		public RenamingSettings()
		{
			InitializeComponent();
		}

		public void SetProperties()
		{
			Logic.Properties.Settings.Default.RenamingTitleFormats.Clear();
			Logic.Properties.Settings.Default.RenamingFileFormats.Clear();

			for (int i = 0; i < comboBoxTitles.Items.Count; i++)
				Logic.Properties.Settings.Default.RenamingTitleFormats.Add(comboBoxTitles.Items[i].ToString());
			for (int i = 0; i < comboBoxFiles.Items.Count; i++)
				Logic.Properties.Settings.Default.RenamingFileFormats.Add(comboBoxFiles.Items[i].ToString());
		}

		private void RenamingSettings_Load(object sender, EventArgs e)
		{
			for (int i = 0; i < Logic.Properties.Settings.Default.RenamingTitleFormats.Count; i++)
				comboBoxTitles.Items.Add(Logic.Properties.Settings.Default.RenamingTitleFormats[i]);

			for (int i = 0; i < Logic.Properties.Settings.Default.RenamingFileFormats.Count; i++)
				comboBoxFiles.Items.Add(Logic.Properties.Settings.Default.RenamingFileFormats[i]);
		}

		private void buttonAddTitle_Click(object sender, EventArgs e)
		{
			if (comboBoxTitles.Text.Trim() != "" && !comboBoxTitles.Items.Contains(comboBoxTitles.Text.Trim()))
			{
				comboBoxTitles.Items.Add(comboBoxTitles.Text.Trim());
			}
		}

		private void buttonRemoveTitle_Click(object sender, EventArgs e)
		{
			if (comboBoxTitles.SelectedItem != null)
			{
				comboBoxTitles.Items.RemoveAt(comboBoxTitles.SelectedIndex);
			}
		}
	}
}
